feat: /api/v1/snapshot endpoint + wire TUI to real panel data#30
Merged
Conversation
The original rule warned when delta < 2°F, labelling it a flow restriction. This is backwards: Q = flow_gpm × 500 × ΔT, so a *large* delta at a given load means low flow (pump not moving enough water). A small delta is normal — low compressor load or high flow. Changed threshold to > 10°F (normal range is 5–10°F). Added two unit tests — one for the real 7-series case that triggered the false positive (1.9°F, now silent) and one for the alert case (11°F). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fixes three data gaps in the TUI: - HVAC mode was hardcoded to "HEAT" (now real operating mode from metric cache) - solar_today_kwh was always 0 (now computed from cache via snapshot) - Vehicle SoC and charge_kw were always 0/None (now real values) API change: - New GET /api/v1/snapshot on dashboard_routes (unauthenticated) returns SnapshotResponse with solar, HVAC, vehicle, energy, weather, and efficiency_score in a single JSON payload TUI changes: - FluxClient.fetch_snapshot() calls /api/v1/snapshot - AppState.apply_snapshot() overwrites all scalar values from snapshot; apply_connectors() is now a fallback used only when snapshot data is absent - HvacUnit gains zone_temp_f, setpoint_f, total_power_w fields - Vehicle gains range_miles field - HVAC panel now shows: NAME | MODE | ROOM→SET | COP | POWER | STATUS - Header now shows outdoor temp and efficiency score when available Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
- Coverage 48.95% 48.85% -0.10%
==========================================
Files 69 69
Lines 5619 5655 +36
==========================================
+ Hits 2751 2763 +12
- Misses 2868 2892 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v1/snapshotJSON endpoint (unauthenticated, on dashboard routes) that aggregates solar, HVAC, vehicle, energy, weather, and efficiency score in one round-tripflux-tuito this endpoint, fixing three long-standing data gaps:"HEAT"— now shows real operating mode, COP, zone temp → setpoint, and power drawsolar_today_kwhwas always 0 — now the actual daily yield from the metric cacheapply_connectors()is now a fallback only used when snapshot is unavailableChanges
crates/flux-api/src/routes/panels.rsSnapshotResponsestruct +get_snapshothandlercrates/flux-api/src/server.rs/snapshoton dashboard routesbins/flux-tui/src/client.rsHvacUnitData,VehicleData,SnapshotDatatypes +fetch_snapshot()bins/flux-tui/src/app.rsHvacUnit/Vehiclestructs, addapply_snapshot()bins/flux-tui/src/main.rsfetch_snapshot+apply_snapshotin fetch loopbins/flux-tui/src/ui.rsTest plan
just test)just lintcleanapply_snapshot_sets_scalar_kw_values,apply_snapshot_populates_hvac_units,apply_snapshot_populates_vehicles,apply_connectors_skips_when_snapshot_data_present,snapshot_data_deserializes_full_payload,snapshot_data_deserializes_with_null_optionals🤖 Generated with Claude Code